﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class User_ProductCatalog : System.Web.UI.Page
{
    BouquetBUS bouBUS = new BouquetBUS();
    DataTable tbBou = new DataTable();
    ShoppingCartBUS cartBUS = new ShoppingCartBUS();
    DataView viewBou;
    DataView mainTable;
    protected void Page_Load(object sender, EventArgs e)
    {

        LoadData();
    }

    private void LoadData()
    {
        tbBou = bouBUS.returnAllBouquet();
        viewBou = new DataView(tbBou);
        viewBou.RowFilter = "C_ID=" + Request.QueryString["id"].ToString();

        mainTable = viewBou;
        CollectionPager1.MaxPages = 100;
        CollectionPager1.PageSize = 9; // số items hiển thị trên một trang
        CollectionPager1.DataSource = mainTable;
        CollectionPager1.BindToControl = dlcatalogProduct;
        dlcatalogProduct.DataSource = CollectionPager1.DataSourcePaged;
        dlcatalogProduct.DataBind();

        //dlcatalogProduct.DataSource = viewBou;
        //dlcatalogProduct.DataBind();
    }
    protected void dlcatalogProduct_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName.Equals("AddCart"))
        {
            cartBUS.Add(e.CommandArgument.ToString(), 1);
            Response.Redirect("ShoppingCart.aspx");
        }
    }
}